﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Silvermoon.Shapes
{
    /// <summary>
    /// Shape that hosts other shapes using the Location and Size of each shape to render.
    /// </summary>
    public class CanvasShape : MultiShape
    {
        public CanvasShape()
            : base()
        {
        }

        public CanvasShape(params Shape[] shapes)
            : base(shapes)
        {
            CalculateSize();
        }

        protected override Shape CreateClone()
        {
            return new CanvasShape();
        }

        private void CalculateSize()
        {
            int w = 0;
            int h = 0;
            foreach (Shape shape in Shapes)
            {
                int sw = shape.Width;
                w = Math.Max(w, shape.Width);
                h = Math.Max(h, shape.Height);
            }
            Size = new Size(w, h);
        }

        protected override void Layout()
        {
            base.Layout();
            CalculateSize();
        }

        protected override void OnLayout()
        {
        }

    }
}
